Fix double resolve() in route-for utilities#3206
Merged
laurakwhit merged 3 commits intocodefreeze-03.02.26from Mar 2, 2026
Merged
Fix double resolve() in route-for utilities#3206laurakwhit merged 3 commits intocodefreeze-03.02.26from
laurakwhit merged 3 commits intocodefreeze-03.02.26from
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Alex-Tideman
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description & motivation 💭
PR #3125 (ESLint v9 upgrade) added
resolve()calls to many routeFor* functions. Functions that compose other routeFor* functions ended up callingresolve()multiple times resulting in the base path being prepended multiple times. For example,routeForWorkflows()calledresolve(routeForNamespace(...))which double-resolved to/{base_path)/{base_path)/namespaces/default/workflows.This PR fixes this by:
resolve()again.AddinggotoResolved()utility that creates a type-safe wrapper aroundgoto()that accepts onlyResolvedRoutevalues, centralizing the eslint-disable forsvelte/no-navigation-without-resolvein one place.Adding brandedResolvedRoutetype to replace SvelteKit'sResolvedPathname(which is juststring) with a branded type that TypeScript enforces at compile time, preventing raw strings from being passed where a resolved route is expected ingotoResolved().exactly once. An additional test automatically fails if a new routeFor* function is added without a corresponding test case.
Screenshots (if applicable) 📸
Design Considerations 🎨
Testing 🧪
How was this tested 👻
Steps for others to test: 🚶🏽♂️🚶🏽♀️
pnpm test src/lib/utilities/route-for-base-path.test.tsRun the following ⬇️
Then go to http://localhost:5252/custom-path/namespaces/default and navigate to different links (e.g.
/workflows)./custom-pathdoes not appear twice in the URL and links work as expectedChecklists
Draft Checklist
Merge Checklist
Issue(s) closed
Related Slack thread.
Docs
Any docs updates needed?